#pragma once
#include <assert.h>
#include <errno.h>
#include <fcntl.h>
#include <sys/epoll.h>
#include <unistd.h>
#include <vector>

namespace zh
{
    class Epoller
    {
    public:
        explicit Epoller(int maxEvents = 1024);
        ~Epoller();

        bool addFD(int fd, uint32_t events);

        bool modifyFD(int fd, uint32_t events);

        bool deleteFD(int fd);

        int wait(int timeout = -1);

        int getEventFD(size_t index) const;

        uint32_t getEvents(size_t index) const;

    private:
        int                             m_epollFD;
        std::vector<struct epoll_event> m_events;
    };
} // namespace zh